package com.hzp.lolnews.ui.discovery.view;

import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.hzp.lolnews.R;
import com.hzp.lolnews.base.BaseRecyclerViewHolder;
import com.hzp.lolnews.bean.DiscoveryNav;

import java.util.List;

/**
 * Created by Administrator on 2016/10/21 0021.
 */
public class DiscoveryHeadAdapter extends RecyclerView.Adapter<BaseRecyclerViewHolder> {

    private List<DiscoveryNav> mList;

    public void setData(List<DiscoveryNav> list) {
        this.mList = list;
        notifyDataSetChanged();
    }

    @Override
    public BaseRecyclerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_litem_dis_head, parent, false);
        return new BaseRecyclerViewHolder(view);
    }

    @Override
    public void onBindViewHolder(BaseRecyclerViewHolder holder, int position) {
        DiscoveryNav discoveryNav = mList.get(position);
        SimpleDraweeView simpleDraweeView = holder.getView(R.id.dis_headSimple);
        simpleDraweeView.setImageURI(discoveryNav.getPicture());
        TextView tvHeadDis = holder.getView(R.id.dis_headTv);
        tvHeadDis.setText(discoveryNav.getName());

    }

    @Override
    public int getItemCount() {
        return mList != null ? mList.size() : 0;
    }
}
